import java.util.ArrayList;
import java.io.Serializable;

public class User implements Serializable {
	private static int nextId = 0;
	private int id;
	private String username, password;
	private ArrayList<String> positions;
	public User(String username, String password) {
		this.username = username;
		this.password = password;
		nextId++;
		id = nextId;
		positions = new ArrayList<String>();
	}

	public int getId() { return id; }
	public String getUsername() { return username; }
	public String getPassword() { return password; }

	public boolean hasPosition(String position) {
		if ("admin".equals(username)) return true;
		return positions.contains(position);
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void addPosition(String position) {
		positions.add(position);
	}

	public void removePosition(String position) {
		positions.remove(position);
	}

	public String toString() {
		return username;
	}
}
